<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <div id="app"></div>

  <script src="../react-js/react.development.js" crossorigin></script>
  <script src="../react-js/react-dom.development.js" crossorigin></script>
  <script src="../react-js/babel.min.js"></script>

  <script type="text/babel">
    class App extends React.Component {
      constructor() {
        super()

        this.state = {
          message: '列表1',
          message2: '列表2',
          moveis: ['1111', '222', '3333', '444'],
          numbers: [10, 26, 36, 50, 80, 74, 60, 90, 100, 8, 44]
        }
      }

      render() {
        //1.
        const list = []
        for(const item of this.state.moveis) {
          list.push(<li>{ item }</li>)
        }

        return (
          <div>
            <h2>{ this.state.message }</h2>
            <ul>
              { list }
            </ul>
            <hr />
            
            { /* 2. */ }
            <h2>{ this.state.message2 }</h2>
            <ul>
              {
                this.state.moveis.map(item => <li>{ item }</li> )
              }
            </ul>
            <hr />

            { /*3. */ }
            <ul>
              {
                this.state.numbers.filter(item => item >= 50 ).map(item => <li>{ item }</li> )
              }
            </ul>
            <hr />

            {/*4. */}
            <ul>
              {
                this.state.numbers.slice(0, 5).map(item => <li>{ item }</li> )
              }  
            </ul>
          </div>
        )
      }

    }

    ReactDOM.render(<App/>, document.getElementById('app'))
  </script>
</body>
</html>